<template>
	<view>


		<gui-page-loading ref="guipageloading">
			<!-- 可以通过插槽添加自定义内容，如 加载提示文本 -->
			<text class="gui-block-text gui-text-small gui-text-center gui-color-gray gui-italic"
				style="padding-top:10rpx;">loading</text>
		</gui-page-loading>


		<view class="gui-list gui-padding">
			<view class="gui-list-items">
				<view class="gui-list-image ucenter-face gui-relative">
					<image class="gui-list-image ucenter-face-image" :src="avatar_pic" mode="aspectFill"></image>
				</view>
				<view class="gui-list-body">
					<view class="gui-list-title" @tap="goto_my_edit()">
						<text class="gui-list-title-text gui-primary-color">{{nickname}}</text>
					</view>
					<gui-tags text="身份切换" bgClass="gui-bg-blue" :size="22" :width="100"
						v-if="member_identity_list.length>1" @tap="change_identity()"></gui-tags>
				</view>
				<text class="gui-list-arrow-right gui-icons gui-color-gray" @tap="goto_my_edit()">&#xe601;</text>
			</view>
		</view>
		<view class="gui-margin-top">
			<gui-swiper :swiperItems="swiperItems" imgMode="scaleToFill" :width="750" :height="330"></gui-swiper>
		</view>
		<view class="gui-list gui-margin-top gui-padding-x">
			<view class="gui-list-items" @tap="goto_order()">
				<text class="gui-list-icon gui-icons gui-color-blue">&#xe62f;</text>
				<view class="gui-list-body gui-border-b">
					<view class="gui-list-title">
						<text class="gui-list-title-text">我的订单</text>

					</view>
				</view>
				<text class="gui-list-arrow-right gui-icons gui-color-gray">&#xe601;</text>
			</view>
			<view class="gui-list-items" @tap="goto_collect()">
				<text class="gui-list-icon gui-icons gui-color-red">&#xe63b;</text>
				<view class="gui-list-body gui-border-b">
					<view class="gui-list-title">
						<text class="gui-list-title-text">我的绑定商家</text>
					</view>
				</view>
				<text class="gui-list-arrow-right gui-icons gui-color-gray">&#xe601;</text>
			</view>
			<view class="gui-list-items" @tap="goto_shouru()">
				<text class="gui-list-icon gui-icons gui-color-red">&#xe612;</text>
				<view class="gui-list-body gui-border-b">
					<view class="gui-list-title">
						<text class="gui-list-title-text">收入</text>
					</view>
				</view>
				<text class="gui-list-arrow-right gui-icons gui-color-gray">&#xe601;</text>
			</view>

			<view class="gui-list-items" @tap="goto_zhujiao_apply()">
				<text class="gui-list-icon gui-icons gui-color-red">&#xe60d;</text>
				<view class="gui-list-body">
					<view class="gui-list-title">
						<text class="gui-list-title-text">助教申请</text>
					</view>
				</view>
				<gui-tags :text="zhujiao_status" :bgClass="zhujiao_class" :size="22"></gui-tags>
				<text class="gui-list-arrow-right gui-icons gui-color-gray">&#xe601;</text>
			</view>
		</view>
		<!-- <view class="ucenter-line gui-bg-white gui-dark-bg-level-3"></view> -->
		<view class="gui-padding-x">
			<view class="gui-list-items" @tap="goto_coach_apply()">
				<text class="gui-list-icon gui-icons gui-color-yellow">&#xe60d;</text>
				<view class="gui-list-body gui-border-b">
					<view class="gui-list-title">
						<text class="gui-list-title-text">教练申请</text>
					</view>
				</view>
				<gui-tags :text="coach_status" :bgClass="coach_class" :size="22"></gui-tags>
				<text class="gui-list-arrow-right gui-icons gui-color-gray">&#xe601;</text>
			</view>
			<view class="gui-list-items" @tap="goto_notice()">
				<text class="gui-list-icon gui-icons gui-color-red">&#xe666;</text>
				<view class="gui-list-body">
					<view class="gui-list-title">
						<text class="gui-list-title-text">我的消息</text>
						<text class="gui-badge gui-bg-red gui-color-white" v-if="no_read_num>0">{{no_read_num}}</text>
					</view>
				</view>
				<text class="gui-list-arrow-right gui-icons gui-color-gray">&#xe601;</text>
			</view>
			<view class="gui-list-items" @tap="goto_trends()">
				<text class="gui-list-icon gui-icons gui-color-red">&#xe69e;</text>
				<view class="gui-list-body">
					<view class="gui-list-title">
						<text class="gui-list-title-text">发动态</text>
					</view>
				</view>
				<text class="gui-list-arrow-right gui-icons gui-color-gray">&#xe601;</text>
			</view>
			<view class="gui-list-items">
				<text class="gui-list-icon gui-icons gui-color-red">&#xe626;</text>
				<view class="gui-list-body">
					<view class="gui-list-title">
						<button type="default" plain="true" open-type="contact" class="gui-list-title-text"
							style="width: 100%;text-align: left;margin-left: -26rpx;border: 0;">联系客服</button>
						<!-- <text class="gui-list-title-text">联系客服</text> -->
					</view>
				</view>
				<text class="gui-list-arrow-right gui-icons gui-color-gray">&#xe601;</text>
			</view>
			<!-- <view class="gui-list-items">
				<text class="gui-list-icon gui-icons gui-color-red">&#xe63b;</text>
				<view class="gui-list-body">
					<view class="gui-list-title">
						<text class="gui-list-title-text">关于我们</text>
					</view>
				</view>
				<text class="gui-list-arrow-right gui-icons gui-color-gray">&#xe601;</text>
			</view> -->
			<view class="gui-list-items" @tap="goto_paiban()">
				<text class="gui-list-icon gui-icons gui-color-red">&#xe64c;</text>
				<view class="gui-list-body">
					<view class="gui-list-title">
						<text class="gui-list-title-text">排班设置</text>
					</view>
				</view>

				<text class="gui-list-arrow-right gui-icons gui-color-gray">&#xe601;</text>
			</view>

			<view class="gui-list-items" @tap="goto_set_money()">
				<text class="gui-list-icon gui-icons gui-color-red">&#xe60a;</text>
				<view class="gui-list-body">
					<view class="gui-list-title">
						<text class="gui-list-title-text">价格设置</text>
					</view>
				</view>

				<text class="gui-list-arrow-right gui-icons gui-color-gray">&#xe601;</text>
			</view>
		</view>
		<view class="ucenter-line gui-bg-white gui-dark-bg-level-3"></view>
		<!-- <view hover-class="gui-tap" @tap="logout()">
			<text class="gui-text-center gui-block-text gui-icons logoff gui-color-gray">&#xe62e; 退出登录</text>
		</view> -->


		<gui-modal ref="guimodal1" title="身份切换">
			<view slot="content" class="gui-padding gui-bg-gray">
				<text class="gui-block-text gui-text-center gui-text gui-color-black gui-bold"
					style="line-height:100rpx; padding:10rpx;">请选择切换的身份</text>
			</view>
			<!-- 利用 flex 布局 可以放置多个自定义按钮哦  -->
			<view slot="btns" class="gui-flex gui-rows gui-space-between">
				<view class="modal-btns gui-flex1" style="margin-left:20rpx;" v-for="(item,index) in shenfen_arr"
					:key="index">
					<text class="modal-btns gui-color-black gui-bold"
						@tap="confirm1(item.identity_name)">{{item.identity_name}}</text>
				</view>

			</view>
		</gui-modal>

		<gui-footer-player-custom :navCurrents="4"></gui-footer-player-custom>
		<gui-iphone-bottom></gui-iphone-bottom>

	</view>
</template>
<script>
	var img =
		"https://images.unsplash.com/photo-1661956602868-6ae368943878?ixlib=rb-1.2.1&ixid=MnwxMjA3fDF8MHxlZGl0b3JpYWwtZmVlZHw2MHx8fGVufDB8fHx8&auto=format&fit=crop&w=600&q=90";
	export default {
		data() {
			return {
				shenfen_arr: [],
				member_identity_list: [],
				nickname: '',
				avatar_pic: img,
				identity_list: [],
				no_read_num: 0,
				items: [
					[80, '', '动态'],
					[100, '', '好友'],
					[50, '', '私信'],
					['￥199', '', '余额']
				],
				swiperItems: [],
				is_qiutong: 0,
				is_zhujiao: 0,
				is_jiaolian: 0,
				qiutong_status: '待申请',
				qiutong_class: 'gui-bg-blue',
				zhujiao_status: '待申请',
				zhujiao_class: 'gui-bg-blue',
				coach_status: '待申请',
				coach_class: 'gui-bg-blue',
				reason: '',
				shop_status: '待申请',
				shop_class: 'gui-bg-blue',
				shop_reason: ""
			}
		},
		methods: {
			goto_trends(){
				uni.navigateTo({
					url:'/pages/assistant/trends'
				})
			},
			goto_paiban() {
				uni.navigateTo({
					url: '/pages/assistant/scheduling'
				})
			},
			confirm1(identity_name) {
				if (identity_name == '用户') {
					uni.reLaunch({
						url: '/pages/index/index'
					})
				}

				if (identity_name == '球伴') {
					uni.reLaunch({
						url: '/pages/index/player_index'
					})
				}

				if (identity_name == '商家') {
					uni.reLaunch({
						url: '/pages/index/shop_index'
					})
				}
			},
			change_identity() {
				this.$refs.guimodal1.open();
			},
			close1() {
				this.$refs.guimodal1.close();
			},
			swiperchange: function(e) {
				console.log(e);
			},
			taped: function(e) {
				uni.showToast({
					title: "您点击了第 " + e + " 个项目",
					icon: "none"
				});
			},
			goto_my_edit() {
				uni.navigateTo({
					url: '/pages/my/my_edit'
				})
			},
			my_info() {
				let _this = this;
				_this.$refs.guipageloading.open();
				uni.request({
					url: _this.serverUrl + '/api.user/my_info', //仅为示例，并非真实接口地址。

					header: {
						token: _this.token
					},

					success: (res) => {

						_this.$refs.guipageloading.close();

						var return_data = res.data;


						console.log(return_data);
						if (return_data.code == 0) {
							_this.nickname = return_data.data.member_info.nickname;
							_this.avatar_pic = return_data.data.member_info.avatar_pic;
							_this.no_read_num = return_data.data.no_read_num;
							_this.swiperItems = return_data.data.banner_list;

							var shop_info = return_data.data.shop_info;
							if (typeof shop_info != 'undefined') {
								_this.shop_reason = shop_info.reason;
								if (shop_info.status == 0) {
									_this.shop_status = '待审核';
									_this.shop_class = 'gui-bg-orange'
								}
								if (shop_info.status == 1) {
									_this.shop_status = '审核通过';
									_this.shop_class = 'gui-bg-green'
								}
								if (shop_info.status == 2) {
									_this.shop_status = '审核拒绝';
									_this.shop_class = 'gui-bg-red'
								}
							}


							var member_identity_list = return_data.data.member_identity_list;
							_this.member_identity_list = member_identity_list;
							_this.shenfen_arr = return_data.data.shenfen_arr;
							console.log(_this.member_identity_list);

							for (var i = 0; i < member_identity_list.length; i++) {
								_this.reason = member_identity_list[i].reason;
								if (member_identity_list[i].identity == 2) {
									_this.is_qiutong = 1;

									if (member_identity_list[i].status == 0) {
										_this.qiutong_status = '待审核';
										_this.qiutong_class = 'gui-bg-orange'

									}

									if (member_identity_list[i].status == 1) {
										_this.qiutong_status = '审核通过';
										_this.qiutong_class = 'gui-bg-green'
									}

									if (member_identity_list[i].status == 2) {
										_this.qiutong_status = '审核拒绝';
										_this.qiutong_class = 'gui-bg-red'
									}
								}
								if (member_identity_list[i].identity == 3) {
									_this.is_zhujiao = 1;

									if (member_identity_list[i].status == 0) {
										_this.zhujiao_status = '待审核';
										_this.zhujiao_class = 'gui-bg-orange'

									}

									if (member_identity_list[i].status == 1) {
										_this.zhujiao_status = '审核通过';
										_this.zhujiao_class = 'gui-bg-green'
									}

									if (member_identity_list[i].status == 2) {
										_this.zhujiao_status = '审核拒绝';
										_this.zhujiao_class = 'gui-bg-red'
									}
								}
								if (member_identity_list[i].identity == 4) {
									_this.is_jiaolian = 1;

									if (member_identity_list[i].status == 0) {
										_this.coach_status = '待审核';
										_this.coach_class = 'gui-bg-orange'

									}

									if (member_identity_list[i].status == 1) {
										_this.coach_status = '审核通过';
										_this.coach_class = 'gui-bg-green'
									}

									if (member_identity_list[i].status == 2) {
										_this.coach_status = '审核拒绝';
										_this.coach_class = 'gui-bg-red'
									}
								}
							}

						}
					}
				});
			},
			goto_order() {
				uni.navigateTo({
					url: '/pages/order/player_list'
				})
			},
			goto_collect() {
				uni.navigateTo({
					url: '/pages/assistant/shop/list'
				})
			},
			goto_qiutong_apply() {

				if (this.qiutong_status == '待审核') {
					uni.showToast({
						title: '您的球童申请已提交，请耐心等待平台审核',
						icon: 'none'
					});

					return;
				}

				if (this.qiutong_status == '审核拒绝') {

					uni.navigateTo({
						url: "/pages/apply/primary",
						success: function() {
							uni.showToast({
								title: '拒绝原因：' + this.reason,
								icon: 'none'
							});
						}
					})


					return;
				}


				uni.navigateTo({
					url: "/pages/apply/primary"
				})

			},
			goto_zhujiao_apply() {

				if (this.zhujiao_status == '待审核') {
					uni.showToast({
						title: '您的助教申请已提交，请耐心等待平台审核',
						icon: 'none'
					});

					return;
				}

				if (this.zhujiao_status == '审核拒绝') {
					uni.showToast({
						title: '拒绝原因：' + this.reason,
						icon: 'none'
					});

					return;
				}


				uni.navigateTo({
					url: "/pages/apply/intermediate"
				})
			},
			goto_coach_apply() {

				if (this.coach_status == '待审核') {
					uni.showToast({
						title: '您的教练申请已提交，请耐心等待平台审核',
						icon: 'none'
					});

					return;
				}

				if (this.coach_status == '审核拒绝') {
					uni.showToast({
						title: '拒绝原因：' + this.reason,
						icon: 'none'
					});

					return;
				}


				uni.navigateTo({
					url: "/pages/apply/senior"
				})
			},
			goto_notice() {
				uni.navigateTo({
					url: '/pages/my/message'
				})
			},
			goto_shangjia_ruzhu() {

				if (this.shop_status == '待审核') {
					uni.showToast({
						title: '您的商家入驻申请已提交，请耐心等待平台审核',
						icon: 'none'
					});

					return;
				}

				if (this.shop_status == '审核拒绝') {
					uni.showToast({
						title: '拒绝原因：' + this.shop_reason,
						icon: 'none'
					});

					return;
				}



				uni.navigateTo({
					url: '/pages/business/ruzhu'
				})
			},
			logout() {
				this.graceJS.removeStorage('token');
				uni.reLaunch({
					url: '/pages/index/index'
				})
			},
			goto_shouru() {
				uni.navigateTo({
					url: '/pages/assistant/shouru'
				})
			},
			goto_set_money() {
				uni.navigateTo({
					url: '/pages/assistant/set_money'
				})
			},

		},
		onLoad: function() {
			this.$globalMethod();
			this.my_info();
		}
	}
</script>
<style scoped>
	.ucenter-face {
		width: 100rpx;
		height: 100rpx;
	}

	.ucenter-face-image {
		width: 100rpx;
		height: 100rpx;
	}

	.ucenter-line {
		height: 20rpx;
		margin: 16rpx 0;
	}

	.logoff {
		line-height: 88rpx;
		font-size: 28rpx;
	}

	.gui-list-title-text {
		line-height: 60rpx;
	}

	.modal-btns {
		line-height: 88rpx;
		font-size: 26rpx;
		text-align: center;
		width: 200rpx;
	}
</style>